<template>
<view class="container">
    <!--轮播图-->
    <view class="header">
        <image :src="imgUrl+banner"></image>
    </view>
    <view class="line">
        
    </view>
    <view class="body">
        <view class="newslist" v-for="(item,index) in school" :key="index" @click="jump(item.id)">
            <image :src="imgUrl+item.img"></image>
            <view class="content">
                <view class="title">学校名称:<text class="name">{{item.name}}</text></view>
                <view class="address">学校地址:<text class="name">{{item.address}}</text></view>
                <view class="more">查看所有课程</view>
            </view>
        </view>
    </view>
</view>
</template>
<script>
import request from '@/util/request.js'	
export default {
	data() {
		return {
			imgUrl:this.url,
			banner:'',
			totalPage:0,
			page:1,
			school:[]
		}
	},
	onLoad:function(){
		uni.showLoading({
		    title: '加载中'  
		});
		this.getBanner()
		this.getSchool()
	},
	methods: {
		getBanner:function(){
			var that = this;
			var data = {'type':3}
			request({
				url: 'banner',
				method: 'get',
				data:data,
				success: (res) => {
					that.banner = res.data.data[0].img
				}
			})
		},
		getSchool:function(){
			var that = this
			var data = {page:this.page}
			request({
				url: 'school/list',
				method: 'get',
				data:data,
				success: (res) => {
					if(res.data.code == 1){
						uni.hideLoading()
						if(that.totalPage == 0){
							that.totalPage = res.data.data.last_page
						}
						if(that.page == 1){
							that.school = res.data.data.data
						}else{
							var school = that.school
							that.school = school.concat(res.data.data.data)
						}
					}
				}
			})
		},
		jump:function(id){
			uni.navigateTo({
				url:'/pages/course/list?id='+id
			});
		}
	}
}
</script>
<style scoped>
	@import url("./index.css");
</style>